#!/usr/bin/env python
# -*- coding: utf-8 -*-

""" By Martin Senande-Rivera
    For Towards and atmosphere more favourable to firestorm development in Europe """

import os
import glob, sys
import numpy as np
import xarray as xr
import pandas as pd

month=sys.argv[1]   # Enter month

path_dmp='./DMP/Months/'
path_outs='./DMP/Monthly_mean/'

# Read files
DMP = xr.open_mfdataset(path_dmp+'DMP_*_'+month+'.nc',concat_dim='time')['DMP']
DMP.values[DMP.values==-0.02]=np.nan

# DMP monthly mean
DMP_mean = DMP.mean(dim='time',skipna=True)
DMP_mean.to_netcdf(path_outs+'DMP_'+month+'.nc')  # Save output



